#include<bits/stdc++.h>
using namespace std;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin>>t;
    while(t--){
        int d[100500]={};
        int v[100500]={};
        int a[100500]={};
        int p[100500]={};
        vector<int> b[100500];
        bool need[100500]={};
        bool cou[100500]={};
        int cnt=0;
        int n,m,l;
        double v1;
        cin>>n>>m>>l>>v1;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
        }
        for(int i=1;i<=m;i++){
            cin>>p[i];
        }
        for(int i=1;i<=m;i++){
            for(int j=1;j<=n;j++){
                if(d[j]>p[i])continue;
                int s=p[i]-d[j];
                double nv;
                if(v[j]*v[j]+2*a[j]*s>0)
                nv=sqrt((double)(v[j]*v[j]+2*a[j]*s));
                else
                nv=0;
                if(nv>v1){
                    b[i].push_back(j);
                    need[j]=1;
            }
        }
    }
    for(int i=1;i<=n;i++){
        if(need[i]){
            cout<<i<<" ";
            cnt++;
        }
    }
    int maxn=-1;
    int maxj=0;
    int num=0;
    while(1){
        for(int i=1;i<=m;i++){
            int val=b[i].size();
            for(int j=0;j<b[i].size();j++){
                    if(cou[b[i][j]]==1)val--;
            }
            if(val>maxn){
                maxn=val;
                maxj=i;
            }
        }
        for(int i=0;i<b[maxj].size();i++){
            cou[b[maxj][i]]=1;
        }
        int flag=0;
        for(int i=1;i<=n;i++){
            if(need[i]&&!cou[i]){
                    flag=1;
                    break;
            }
        }
        if(flag==0)break;
        num++;
    }
    cout<<cnt<<" "<<m-num<<"\n";
    }

    return 0;
}
